package com.example.monitoringsystem.controller;

import com.example.monitoringsystem.bean.User;
import com.example.monitoringsystem.service.StatesService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class StatesController {
    @Autowired
    private StatesService statesService;

    //更改是否已阅
    @PostMapping("/haveBeenRead")
    @ResponseBody
    public String changeHaveBeenRead(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        statesService.changeHaveBeenRead(user.getId());
        return "success";
    }


    //更改是否打印
    @PostMapping("/haveBeenPrinted")
    @ResponseBody
    public String changeHavePrinted(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        statesService.changeHaveBeenPrinted(user.getId());
        return "success";
    }
}
